/*
 * 组织结构展示
 */
var url = '', jsonData = '';
$(function(){
	loadData();
});

function loadData(){
	loadTopCSS();
	/**
	 * HC指标
	 */
	loadHCTarget();
	 
}

function loadTopCSS() {
	$("#li6").addClass("navdown");
}

/*
 * HC指标
 */
function loadHCTarget() {
	url = ctx + '/show/entryType';
	 
	var departmentId = $('#departmentId').val();
	var startTime = $('#startHCTarget').val();
	var endTime = $('#endHCTarget').val();
	
	if (startTime.length==0||endTime.length==0||startTime==endTime) {
		
		var date = new Date();
		var year = date.getFullYear();
		var month = date.getMonth()+1;
		var day = date.getDate();
		
		var startYear = year-1;
		
		startTime = startYear+"-"+month;
		endTime = year+"-"+month;
		
	}
	
	$('#startHCTarget').val(startTime);
	$('#endHCTarget').val(endTime);
	
	
	
	jsonData = {departmentId:departmentId,startTime:startTime,endTime:endTime};
	var  returnData= commonAjax();
	console.log(returnData);
	
	//initBarChart(returnData.title,returnData.data,returnData.dates,returnData.name1,document.getElementById('HCTargetMain'));
	//initLineAndTimeChart(returnData.title,returnData.data,returnData.dates,returnData.name1,document.getElementById('HCTargetMain'));
	initBarChaert3(returnData.title,returnData.data[0].data,returnData.data[1].data,returnData.dates,returnData.name1,document.getElementById('HCTargetMain'));
	
}

function commonAjax(){
	var result = '';
	$.ajax({
		type: 'GET',
		data: jsonData,
	    url: url,
	    async: false,
	    dataType:"json",
	    success: function(data){
	    	result = data;
	    },
	    error: function(){
	    }
	});
	return result;
}
/**
 *  ！！！！！！！！！！！异步请求！！！！！！！！！！！！！
 */
/*function commonAjax(fun, dataType){
	$.ajax({
		type: 'POST',
		data: jsonData,
	    url: url,
	    dataType: dataType,
	    success: function(data){
	    	fun(data);
	    },
	    error: function(){
	    }
	});
}*/